import 'package:flutter/gestures.dart';
import 'package:flutter/material.dart';
import 'package:logger/logger.dart';

class TextStyleRoute extends StatefulWidget {
  const TextStyleRoute({Key? key}) : super(key: key);

  @override
  State<StatefulWidget> createState() => _TextStyleRouteState();
}

class _TextStyleRouteState extends State<TextStyleRoute> {
  final logger = Logger(printer: PrettyPrinter());

  @override
  void initState() {
    super.initState();
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: const Text("文本及样式"),
      ),
      body: Center(
        child: Column(
          children: <Widget>[
            const Text(
              "Hello world",
              textAlign: TextAlign.left,
            ),
            SizedBox.fromSize(size: const Size.fromHeight(20)),
            Text(
              "Hello world! I'm Jack. " * 10,
              maxLines: 1,
              overflow: TextOverflow.ellipsis,
            ),
            SizedBox.fromSize(size: const Size.fromHeight(20)),
            const Text("Hello world", textScaleFactor: 1.5),
            SizedBox.fromSize(size: const Size.fromHeight(20)),
            Text("Hello world " * 10, textAlign: TextAlign.center),
            SizedBox.fromSize(size: const Size.fromHeight(20)),
            Text(
              "Hello world",
              style: TextStyle(
                  color: Colors.blue,
                  fontSize: 18.0,
                  height: 1.2,
                  fontFamily: "Courier",
                  background: Paint()..color = Colors.yellow,
                  decoration: TextDecoration.underline,
                  decorationStyle: TextDecorationStyle.solid),
            ),
            SizedBox.fromSize(size: const Size.fromHeight(20)),
            Text.rich(
              TextSpan(
                children: <TextSpan>[
                  const TextSpan(text: "Home: "),
                  TextSpan(
                    text: "https://flutterchina.club",
                    style: const TextStyle(
                      color: Colors.blue,
                    ),
                    recognizer: TapGestureRecognizer()
                      ..onTap = () => logger.i("点击了..."),
                  ),
                ],
              ),
            ),
            SizedBox.fromSize(size: const Size.fromHeight(20)),
            DefaultTextStyle(
              style: const TextStyle(
                color: Colors.red,
                fontSize: 32.0,
                fontFamily: 'jinglei',
              ),
              child: Column(
                crossAxisAlignment: CrossAxisAlignment.start,
                children: const <Widget>[
                  Text("hello world"),
                  Text("I am Jack"),
                  Text(
                    "I am Jack",
                    style: TextStyle(inherit: false, color: Colors.green),
                  ),
                ],
              ),
            ),
          ],
        ),
      ),
    );
  }
}
